package com.dlry.entity;
// Generated 2016-10-31 13:57:37 by Hibernate Tools 3.6.0.Final

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * DlMeetingRoomBooking generated by hbm2java
 */
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "entityCache")
@Cacheable(true)
@Entity
@Table(name = "dl_meeting_room_booking")
public class DlMeetingRoomBooking implements java.io.Serializable {

	/**
	 * 
	 */
	@Transient
	private static final long serialVersionUID = 6622442481384062899L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	@Column(name = "name")
	private String name;
	@Column(name = "booking_time")
	private Timestamp bookingTime;
	@ManyToOne
	@JoinColumn(name = "room_id")
	private DlMeetingRoom room;
	@Column(name = "end_time")
	private Timestamp endTime;
	@Column(name = "create_time")
	private Timestamp createdTime;
	@Column(name = "update_time")
	private Timestamp updateTime;
	@Column(name = "username")
	private String userName;
	@Column(name = "phone")
	private String phone;
	@Column(name = "verification_code")
	private String verificationCode;

	public Timestamp getEndTime() {
		return endTime;
	}

	public void setEndTime(Timestamp endTime) {
		this.endTime = endTime;
	}

	public Timestamp getCreatedTime() {
		return createdTime;
	}

	public Timestamp getUpdateTime() {
		return updateTime;
	}

	public DlMeetingRoomBooking() {
	}

	public DlMeetingRoomBooking(int roomId, String name, Timestamp bookingTime) {
		// this.roomId = roomId;
		this.name = name;
		this.bookingTime = bookingTime;
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	// public int getRoomId() {
	// return this.roomId;
	// }
	//
	// public void setRoomId(int roomId) {
	// this.roomId = roomId;
	// }

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Timestamp getBookingTime() {
		return this.bookingTime;
	}

	public void setBookingTime(Timestamp bookingTime) {
		this.bookingTime = bookingTime;
	}

	public void setBookingTimestr(String bookingTimestr) {
		try {
			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:ss");
			Date date = format.parse(bookingTimestr);
			Timestamp timestamp = new Timestamp(date.getTime());
			this.bookingTime = timestamp;
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}

	public void setEndTimestr(String endTimestr) {
		try {
			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:ss");
			Date date = format.parse(endTimestr);
			Timestamp timestamp = new Timestamp(date.getTime());
			this.endTime = timestamp;
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public DlMeetingRoom getRoom() {
		return room;
	}

	public void setRoom(DlMeetingRoom room) {
		this.room = room;
	}

	public void setCreatedTime(Timestamp createdTime) {
		this.createdTime = createdTime;
	}

	public void setUpdateTime(Timestamp updateTime) {
		this.updateTime = updateTime;
	}

	public String getDurationTime() {
		SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		SimpleDateFormat format2 = new SimpleDateFormat("HH:mm");
		String from = format1.format(getBookingTime());
		String to = format2.format(getEndTime());
		return from + "至" + to;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getVerificationCode() {
		return verificationCode;
	}

	public void setVerificationCode(String verificationCode) {
		this.verificationCode = verificationCode;
	}

}
